<template>
<div class="tabcontrol">
  <div v-for="(item, index) in titles" :key="item.labeltab" class="tab-control-item" 
  :class="{tabcomtrolactive:index === currentindex}" @click="tabcontrolitem(index)">
      <span>{{item}}</span>
  </div>
  </div>
</template>

<script>
export default {
    name:'tabcontrol',
    props:{
        titles:{
            type:Array,
            defalut(){
                return []
            }
        }
    },
    data () {
        return {
            currentindex: 0
        }
    },
    methods: {
        tabcontrolitem(index){
            this.currentindex = index
            this.$emit('tabchange', index)
        }
    }
}
</script>

<style>
.tabcontrol{
    display: flex;
    text-align: center;
    height: 44px;
    line-height: 44px;
    font-size: 15px;
    background-color: #fff;
}
.tab-control-item{
    flex: 1;
}
.tabcomtrolactive span{
    border-bottom: 3px solid red;
    padding-bottom: 5px;
}
.tabcomtrolactive{
    color: red;
}
</style>